//
//  LGDiseaseOverviewInspectHeader.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/10/16.
//  异常检查项

#import "LGDiseaseOverviewInspectHeader.h"

@interface LGDiseaseOverviewInspectHeader()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIView *lineView;
/**   */
@property (nonatomic , strong)UILabel *dateLabel;


@end

@implementation LGDiseaseOverviewInspectHeader

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.clipsToBounds = YES;
        [self addSubview:self.baseView];
        [self.baseView addSubview:self.lineView];
        [self.baseView addSubview:self.dateLabel];
        [self createTitleView];
        [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(viewPix(16));
            make.right.equalTo(self).offset(-viewPix(16));
            make.top.bottom.equalTo(self);
        }];
        [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.lineView.mas_right).offset(viewPix(12));
            make.centerY.equalTo(self.lineView);
        }];
    }
    return self;
}

-(void)setDateString:(NSString *)dateString{
    _dateString = dateString;
    self.dateLabel.text = dateString;
}

-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B2BDC7" offset:CGSizeMake(0, 2) opacity:0.15 radius:0];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UIView *)lineView{
    if(!_lineView){
        _lineView = [[UIView alloc] initWithFrame:CGRectMake(viewPix(12), viewPix(10), 4, viewPix(14))];
        _lineView.backgroundColor = [UIColor colorWithString:@"#77D4C6"];
        _lineView.cornerRidus = 2;
    }
    return _lineView;
}

-(UILabel *)dateLabel{
    if(!_dateLabel){
        _dateLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(14, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _dateLabel;
}

-(void)createTitleView{
    CGFloat marginTop = viewPix(35);
    CGFloat nameWidth = isPad ? viewPix(280) : viewPix(110);
    CGFloat resultWidth = isPad ? viewPix(140) : viewPix(70);
    CGFloat itemWidth  = (Screen_W-viewPix(32)-viewPix(16)-viewPix(15)-nameWidth-resultWidth)/2.0;
    UILabel *titleLabel = [UILabel lableWithText:@"项目" colorString:@"#666666" textFont:LGFont(13) textAlignment:NSTextAlignmentLeft lines:1];
    titleLabel.frame = CGRectMake(viewPix(28), marginTop, nameWidth, viewPix(20));
    [self addSubview:titleLabel];
    
    UILabel *resultLabel = [UILabel lableWithText:@"结果" colorString:@"#666666" textFont:LGFont(13) textAlignment:NSTextAlignmentLeft lines:1];
    resultLabel.frame = CGRectMake(kMaxX(titleLabel.frame)+viewPix(5), marginTop, resultWidth, viewPix(20));
    [self addSubview:resultLabel];
    
    UILabel *unitLabel = [UILabel lableWithText:@"单位" colorString:@"#666666" textFont:LGFont(13) textAlignment:NSTextAlignmentLeft lines:1];
    unitLabel.frame = CGRectMake(kMaxX(resultLabel.frame)+viewPix(5), marginTop, itemWidth, viewPix(20));
    [self addSubview:unitLabel];
    
    UILabel *referenceLabel = [UILabel lableWithText:@"参考值" colorString:@"#666666" textFont:LGFont(13) textAlignment:NSTextAlignmentLeft lines:1];
    referenceLabel.frame = CGRectMake(kMaxX(unitLabel.frame)+viewPix(5), marginTop, itemWidth, viewPix(20));
    [self addSubview:referenceLabel];
}

@end
